﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using System.Text;
using Global.Class.Library;

namespace DataTransferObject.MetaDataList
{
    public class ListItemBrandMaster : NotifyPropertyChangeObject
    {
        private int itemBrandID;

        private DateTime entryDate;
        
        private int ancestorID;        

        private string description;
        private string other;


        public ListItemBrandMaster()
        {
            GlobalDefaultValue.Apply(this);
            this.EntryDate = DateTime.Now;
        }

        #region Properties


        [DefaultValue(-1)]
        public int ItemBrandID
        {
            get { return this.itemBrandID; }
            set { ApplyPropertyChange<ListItemBrandMaster, int>(ref this.itemBrandID, o => o.ItemBrandID, value); }
        }

        [DefaultValue(typeof(DateTime), "01/01/1900")]
        public DateTime EntryDate
        {
            get { return this.entryDate; }
            set { ApplyPropertyChange<ListItemBrandMaster, DateTime>(ref this.entryDate, o => o.EntryDate, value); }
        }

        [DefaultValue(0)]
        public int AncestorID
        {
            get { return this.ancestorID; }
            set { ApplyPropertyChange<ListItemBrandMaster, int>(ref this.ancestorID, o => o.AncestorID, value); }
        }     
        
        [DefaultValue("")]
        public string Description
        {
            get { return this.description; }
            set { ApplyPropertyChange<ListItemBrandMaster, string>(ref this.description, o => o.Description, value); }
        }


        [DefaultValue("")]
        public string Other
        {
            get { return this.other; }
            set { ApplyPropertyChange<ListItemBrandMaster, string>(ref this.other, o => o.Other, value); }
        }
        
        #endregion

        protected override System.Collections.Generic.List<ValidationRule> CreateRules()
        {
            List<ValidationRule> validationRules = base.CreateRules();
            validationRules.Add(new SimpleValidationRule("Description", "Reference cannot be blank.", delegate { return this.Description.Length != 0; }));
            validationRules.Add(new SimpleValidationRule("AncestorID", "Command type cannot be empty.", delegate { return (this.AncestorID == 0 || this.AncestorID != this.ItemBrandID) ; }));
            
            return validationRules;
        }
    }
}
